using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using FetCo.Data;
using ADESSA.Business;
using ADESSA.Entities;
using FetCo.Framework;
using FetCo.Web;

public partial class _Default : System.Web.UI.Page
{
    #region Viarible
    public int NoCountStart
    {
        get { return Convert.ToInt32(ViewState["NoCountStart"]); }
        set { ViewState["NoCountStart"] = value; }
    }
    int CountArticle = 0;
    #endregion
    protected string M_HomeRight = "";
    protected string M_HomeCenter = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
            return;
        LoadProsell();
        LoadSession();
        LoadProselltop();
        LoadProBuytop();
        LoadFeaturedCom();
        LoadTraceShow();
        LoadFeatureCountry();
        M_HomeRight = AllAds.LoadHomeRight();
        M_HomeCenter = AllAds.LoadHomeCenter();
    }

    #region Load product Sell
    private void LoadProsell()
    {
        #region get not gold member
        Criteria cri = new Criteria();
        cri.addJoin(Member._Table, ProductSell._Table + "." + ProductSellColumns.MemberId, Member._Table + "." + MemberColumns.MemberID, Condition.EQUAL, Condition.LEFT_JOIN);
        cri.add(ProductSellColumns.Enable, 1, Condition.EQUAL, Condition.AND);
        cri.add(ProductSellColumns.Approved, 1, Condition.EQUAL, Condition.AND);
        cri.add("[" + ProductSell._Table + "].[" + ProductSellColumns.Not_Clear + "]", 0, Condition.EQUAL, Condition.AND);
        cri.add(Member._Table + "." + MemberColumns.GoldMember, 0, Condition.EQUAL, Condition.AND);
        ProductSellCollection _ProductSellCollectionNotgold = ProductSellService.GetProductSellListByParam("[" + ProductSell._Table + "].[" + ProductSellColumns.CreatedDate + "]", OrderDirection.DESC, cri.Criter);
        #endregion
        #region get gold member
        Criteria crit = new Criteria();
        crit.addJoin(Member._Table, ProductSell._Table + "." + ProductSellColumns.MemberId, Member._Table + "." + MemberColumns.MemberID, Condition.EQUAL, Condition.LEFT_JOIN);
        crit.add(ProductSellColumns.Enable, 1, Condition.EQUAL, Condition.AND);
        crit.add(ProductSellColumns.Approved, 1, Condition.EQUAL, Condition.AND);
        crit.add("[" + ProductSell._Table + "].[" + ProductSellColumns.Not_Clear + "]", 0, Condition.EQUAL, Condition.AND);
        crit.add(Member._Table + "." + MemberColumns.GoldMember, 1, Condition.EQUAL, Condition.AND);
        ProductSellCollection _ProductSellCollection = ProductSellService.GetProductSellListByParam("[" + ProductSell._Table + "].[" + ProductSellColumns.CreatedDate + "]", OrderDirection.DESC, crit.Criter);
        #endregion
        if (_ProductSellCollection.Count < 31)
        {
            for (int i = 0; i < _ProductSellCollectionNotgold.Count; i++)
            {
                _ProductSellCollection.Add(_ProductSellCollectionNotgold[i]);
                if (_ProductSellCollection.Count > 31)
                    break;
            }
        }
        ArrayList arrypro1 = new ArrayList();
        ArrayList arrypro2 = new ArrayList();
        ArrayList arrypro3 = new ArrayList();
        ArrayList arrypro4 = new ArrayList();
        if (_ProductSellCollection.Count > 0)
        {
            for (int i = 0; i < _ProductSellCollection.Count; i++)
            {
                if (i < 8)
                {
                    arrypro1.Add(_ProductSellCollection[i]);
                }
                else if (i > 7 && i < 16)
                {
                    arrypro2.Add(_ProductSellCollection[i]);
                }
                else if (i > 15 && i < 24)
                {
                    arrypro3.Add(_ProductSellCollection[i]);
                }
                else if (i > 23 && i < 32)
                {
                    arrypro4.Add(_ProductSellCollection[i]);
                }
            }
            rptsellPro1.DataSource = arrypro1;
            rptsellPro1.DataBind();
            rptProbuy1.DataSource = arrypro2;
            rptProbuy1.DataBind();
            rptsellPro2.DataSource = arrypro3;
            rptsellPro2.DataBind();
            rptProbuy2.DataSource = arrypro4;
            rptProbuy2.DataBind();

        }

    }
    protected void rptProbuy1_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        ProductSell _ProductSell = (ProductSell)e.Item.DataItem;
        Literal cotentliandiv = (Literal)e.Item.FindControl("cotentliandiv");
        Literal ltrTitle = (Literal)e.Item.FindControl("ltrTitle");
        HtmlAnchor hftimg = (HtmlAnchor)e.Item.FindControl("hftimg");
        HtmlAnchor hfttitle = (HtmlAnchor)e.Item.FindControl("hfttitle");
        HtmlImage img = (HtmlImage)e.Item.FindControl("img");
        hfttitle.HRef = "ProductsellDetail-" + _ProductSell.ProductId + "-" + Utilitys.StripDiacritics(Utility.Splitword(_ProductSell.Title)) + ".aspx";
        hftimg.HRef = "ProductsellDetail-" + _ProductSell.ProductId + "-" + Utilitys.StripDiacritics(Utility.Splitword(_ProductSell.Title)) + ".aspx";
        hfttitle.Attributes["title"] = _ProductSell.Title;
        hftimg.Attributes["title"] = _ProductSell.Title;
        img.Attributes["alt"] = _ProductSell.Title;
        ltrTitle.Text = Utilitys.ShortSummary(30, _ProductSell.Title);
        if (!string.IsNullOrEmpty(_ProductSell.Image))
        {
            img.Src = "photos/" + _ProductSell.Image;
        }
        else
        {
            img.Visible = false;
        }
        int itemcout = e.Item.ItemIndex + 1;
        if (itemcout != 1 && itemcout != 5)
        {
            cotentliandiv.Text = "<li class='doc'></li>";
        }
        else if (itemcout == 5)
        {
            cotentliandiv.Text = "<div class='clr'></div>";
        }
        else
        {
            cotentliandiv.Text = "";
        }



    }
    protected void rptProbuy2_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        ProductSell _ProductSell = (ProductSell)e.Item.DataItem;
        Literal cotentliandiv = (Literal)e.Item.FindControl("cotentliandiv");
        Literal ltrTitle = (Literal)e.Item.FindControl("ltrTitle");
        HtmlAnchor hftimg = (HtmlAnchor)e.Item.FindControl("hftimg");
        HtmlAnchor hfttitle = (HtmlAnchor)e.Item.FindControl("hfttitle");
        HtmlImage img = (HtmlImage)e.Item.FindControl("img");
        hfttitle.HRef = "ProductsellDetail-" + _ProductSell.ProductId + "-" + Utilitys.StripDiacritics(Utility.Splitword(_ProductSell.Title)) + ".aspx";
        hftimg.HRef = "ProductsellDetail-" + _ProductSell.ProductId + "-" + Utilitys.StripDiacritics(Utility.Splitword(_ProductSell.Title)) + ".aspx";
        hfttitle.Attributes["title"] = _ProductSell.Title;
        hftimg.Attributes["title"] = _ProductSell.Title;
        img.Attributes["alt"] = _ProductSell.Title;
        ltrTitle.Text = Utilitys.ShortSummary(30, _ProductSell.Title);
        if (!string.IsNullOrEmpty(_ProductSell.Image))
        {
            img.Src = "photos/" + _ProductSell.Image;
        }
        else
        {
            img.Visible = false;
        }
        int itemcout = e.Item.ItemIndex + 1;
        if (itemcout != 1 && itemcout != 5)
        {
            cotentliandiv.Text = "<li class='doc'></li>";
        }
        else if (itemcout == 5)
        {
            cotentliandiv.Text = "<div class='clr'></div>";
        }
        else
        {
            cotentliandiv.Text = "";
        }


    }
    protected void rptsellPro1_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        ProductSell _ProductSell = (ProductSell)e.Item.DataItem;
        Literal cotentliandiv = (Literal)e.Item.FindControl("cotentliandiv");
        Literal ltrTitle = (Literal)e.Item.FindControl("ltrTitle");
        HtmlAnchor hftimg = (HtmlAnchor)e.Item.FindControl("hftimg");
        HtmlAnchor hfttitle = (HtmlAnchor)e.Item.FindControl("hfttitle");
        HtmlImage img = (HtmlImage)e.Item.FindControl("img");
        hfttitle.HRef = "ProductsellDetail-" + _ProductSell.ProductId + "-" + Utilitys.StripDiacritics(Utility.Splitword(_ProductSell.Title)) + ".aspx";
        hftimg.HRef = "ProductsellDetail-" + _ProductSell.ProductId + "-" + Utilitys.StripDiacritics(Utility.Splitword(_ProductSell.Title)) + ".aspx";
        hfttitle.Attributes["title"] = _ProductSell.Title;
        hftimg.Attributes["title"] = _ProductSell.Title;
        img.Attributes["alt"] = _ProductSell.Title;
        ltrTitle.Text = Utilitys.ShortSummary(30, _ProductSell.Title);
        if (!string.IsNullOrEmpty(_ProductSell.Image))
        {
            img.Src = "photos/" + _ProductSell.Image;
        }
        else
        {
            img.Visible = false;
        }
        int itemcout = e.Item.ItemIndex + 1;
        if (itemcout != 1 && itemcout != 5)
        {
            cotentliandiv.Text = "<li class='doc'></li>";
        }
        else if (itemcout == 5)
        {
            cotentliandiv.Text = "<div class='clr'></div>";
        }
        else
        {
            cotentliandiv.Text = "";
        }


    }
    protected void rptsellPro2_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        ProductSell _ProductSell = (ProductSell)e.Item.DataItem;
        Literal cotentliandiv = (Literal)e.Item.FindControl("cotentliandiv");
        Literal ltrTitle = (Literal)e.Item.FindControl("ltrTitle");
        HtmlAnchor hftimg = (HtmlAnchor)e.Item.FindControl("hftimg");
        HtmlAnchor hfttitle = (HtmlAnchor)e.Item.FindControl("hfttitle");
        HtmlImage img = (HtmlImage)e.Item.FindControl("img");
        hfttitle.HRef = "ProductsellDetail-" + _ProductSell.ProductId + "-" + Utilitys.StripDiacritics(Utility.Splitword(_ProductSell.Title)) + ".aspx";
        hftimg.HRef = "ProductsellDetail-" + _ProductSell.ProductId + "-" + Utilitys.StripDiacritics(Utility.Splitword(_ProductSell.Title)) + ".aspx";
        hfttitle.Attributes["title"] = _ProductSell.Title;
        hftimg.Attributes["title"] = _ProductSell.Title;
        img.Attributes["alt"] = _ProductSell.Title;
        ltrTitle.Text = Utilitys.ShortSummary(30, _ProductSell.Title);
        if (!string.IsNullOrEmpty(_ProductSell.Image))
        {
            img.Src = "photos/" + _ProductSell.Image;
        }
        else
        {
            img.Visible = false;
        }
        int itemcout = e.Item.ItemIndex + 1;
        if (itemcout != 1 && itemcout != 5)
        {
            cotentliandiv.Text = "<li class='doc'></li>";
        }
        else if (itemcout == 5)
        {
            cotentliandiv.Text = "<div class='clr'></div>";
        }
        else
        {
            cotentliandiv.Text = "";
        }


    }
    #endregion
    #region MyRegion
    //private void LoadProBuyTop()
    //{
    //    Criteria cri = new Criteria();
    //    cri.add(ProductSellColumns.Enable, 1, Condition.EQUAL, Condition.AND);
    //    cri.add(ProductSellColumns.Approved, 1, Condition.EQUAL, Condition.AND);
    //    //cri.add("[" + ProductSell._Table + "].[" + ProductSellColumns.IsDelete+ "]", 1, Condition.NOT_EQUAL, Condition.AND);
    //    ProductSellCollection _ProductSellCollection = ProductSellService.GetProductSellListByParam("[" + ProductSell._Table + "].[" + ProductSellColumns.Order + "],[" + ProductSell._Table + "].[" + ProductSellColumns.CreatedDate + "]", OrderDirection.ASC, cri.Criter);
    //    ArrayList arrypro1 = new ArrayList();
    //    ArrayList arrypro2 = new ArrayList();
    //    if (_ProductSellCollection.Count > 0)
    //    {
    //        for (int i = 0; i < _ProductSellCollection.Count; i++)
    //        {
    //            if (i < 8)
    //            {
    //                arrypro1.Add(_ProductSellCollection[i]);
    //            }
    //            else if (i > 7 && i < 16)
    //            {
    //                arrypro2.Add(_ProductSellCollection[i]);
    //            }
    //        }
    //        rptsellPro1.DataSource = arrypro1;
    //        rptsellPro1.DataBind();
    //        rptsellPro2.DataSource = arrypro2;
    //        rptsellPro2.DataBind();
    //    }

    //}
    #endregion
    #region LoadSession
    private void LoadSession()
    {
        if (Session["MemberId"] != null)
        {
            mid_sign_in.Visible = false;
            mid_sign_out.Visible = true;
        }
        else
            mid_sign_out.Visible = false;
    }

    #endregion
    #region Load ProductSell top
    private void LoadProselltop()
    {
        int OutTotal = 0;
        #region get not gold member
        Criteria cri = new Criteria();
        cri.addJoin(Member._Table, ProductSell._Table + "." + ProductSellColumns.MemberId, Member._Table + "." + MemberColumns.MemberID, Condition.EQUAL, Condition.LEFT_JOIN);
        cri.add(ProductSellColumns.Enable, 1, Condition.EQUAL, Condition.AND);
        cri.add(ProductSellColumns.Approved, 1, Condition.EQUAL, Condition.AND);
        cri.add("[" + ProductSell._Table + "].[" + ProductSellColumns.Not_Clear + "]", 0, Condition.EQUAL, Condition.AND);
        cri.add(Member._Table + "." + MemberColumns.GoldMember, 0, Condition.EQUAL, Condition.AND);
        ProductSellCollection _ProductSellCollectionNotgold = ProductSellService.GetProductSellListByParam("[" + ProductSell._Table + "].[" + ProductSellColumns.Viewed + "]", OrderDirection.DESC, 1, 20, cri.Criter, out OutTotal);
        #endregion
        #region get gold member
        Criteria crit = new Criteria();
        crit.addJoin(Member._Table, ProductSell._Table + "." + ProductSellColumns.MemberId, Member._Table + "." + MemberColumns.MemberID, Condition.EQUAL, Condition.LEFT_JOIN);
        crit.add(ProductSellColumns.Enable, 1, Condition.EQUAL, Condition.AND);
        crit.add(ProductSellColumns.Approved, 1, Condition.EQUAL, Condition.AND);
        crit.add("[" + ProductSell._Table + "].[" + ProductSellColumns.Not_Clear + "]", 0, Condition.EQUAL, Condition.AND);
        crit.add(Member._Table + "." + MemberColumns.GoldMember, 1, Condition.EQUAL, Condition.AND);
        ProductSellCollection _ProductSellCollection = ProductSellService.GetProductSellListByParam("[" + ProductSell._Table + "].[" + ProductSellColumns.Viewed + "]", OrderDirection.DESC, 1, 20, crit.Criter, out OutTotal);
        #endregion
        if (_ProductSellCollection.Count < 21)
        {
            for (int i = 0; i < _ProductSellCollectionNotgold.Count; i++)
            {
                _ProductSellCollection.Add(_ProductSellCollectionNotgold[i]);
                if (_ProductSellCollection.Count > 19)
                    break;
            }
        }
        if (_ProductSellCollection.Count > 0)
        {
            rptProSell.DataSource = _ProductSellCollection;
            rptProSell.DataBind();
        }
    }
    protected void rptProSell_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        ProductSell _ProductSell = (ProductSell)e.Item.DataItem;
        Literal ltrTitle = (Literal)e.Item.FindControl("ltrTitle");
        Literal ltrDatetime = (Literal)e.Item.FindControl("ltrDatetime");
        HtmlAnchor hrfTitle = (HtmlAnchor)e.Item.FindControl("hrfTitle");
        HtmlImage img = (HtmlImage)e.Item.FindControl("img");
        hrfTitle.HRef = "ProductsellDetail-" + _ProductSell.ProductId + "-" + Utilitys.StripDiacritics(Utility.Splitword(_ProductSell.Title)) + ".aspx";
        hrfTitle.Attributes["title"] = _ProductSell.Title;
        img.Attributes["alt"] = _ProductSell.Title;
        ltrTitle.Text = Utilitys.ShortSummary(30, _ProductSell.Title);
        DateTime dt = _ProductSell.CreatedDate;
        string Day = dt.Day.ToString();
        string Month = Utilitys.converMonth(dt.Month.ToString());
        ltrDatetime.Text = Day + " " + Month;
        Criteria cri = new Criteria();
        cri.add(CompanyColumns.MemberID, _ProductSell.MemberId, Condition.EQUAL, Condition.AND);
        CompanyCollection _CompanyCollection = CompanyService.GetCompanyListByParam(CompanyColumns.CompanyID, OrderDirection.ASC, cri.Criter);
        if (_CompanyCollection.Count > 0)
        {
            Country _Country = CountryService.GetCountry(_CompanyCollection[0].Country);
            if (_Country != null)
            {
                if (!string.IsNullOrEmpty(_Country.Img))
                {
                    img.Src = "photos/" + _Country.Img;
                }
                else
                {
                    img.Visible = false;
                }
            }
        }
    }
    #endregion
    #region Load ProductBuy top
    private void LoadProBuytop()
    {
        int OutTotal = 0;
        #region get not gold member
        Criteria cri = new Criteria();
        cri.addJoin(Member._Table, ProductBuy._Table + "." + ProductBuyColumns.MemberId, Member._Table + "." + MemberColumns.MemberID, Condition.EQUAL, Condition.LEFT_JOIN);
        cri.add(ProductBuyColumns.Enable, 1, Condition.EQUAL, Condition.AND);
        cri.add(ProductBuyColumns.Approved, 1, Condition.EQUAL, Condition.AND);
        cri.add("[" + ProductBuy._Table + "].[" + ProductBuyColumns.Not_Clear + "]", 0, Condition.EQUAL, Condition.AND);
        cri.add(Member._Table + "." + MemberColumns.GoldMember, 0, Condition.EQUAL, Condition.AND);
        ProductBuyCollection _ProductBuyCollectionNotgold = ProductBuyService.GetProductBuyListByParam("[" + ProductBuy._Table + "].[" + ProductBuyColumns.Viewed + "]", OrderDirection.DESC, 1, 20, cri.Criter, out OutTotal);
        #endregion
        #region get gold member
        Criteria crit = new Criteria();
        crit.addJoin(Member._Table, ProductBuy._Table + "." + ProductBuyColumns.MemberId, Member._Table + "." + MemberColumns.MemberID, Condition.EQUAL, Condition.LEFT_JOIN);
        crit.add(ProductBuyColumns.Enable, 1, Condition.EQUAL, Condition.AND);
        crit.add(ProductBuyColumns.Approved, 1, Condition.EQUAL, Condition.AND);
        crit.add("[" + ProductBuy._Table + "].[" + ProductBuyColumns.Not_Clear + "]", 0, Condition.EQUAL, Condition.AND);
        crit.add(Member._Table + "." + MemberColumns.GoldMember, 1, Condition.EQUAL, Condition.AND);
        ProductBuyCollection _ProductBuyCollection = ProductBuyService.GetProductBuyListByParam("[" + ProductBuy._Table + "].[" + ProductBuyColumns.Viewed + "]", OrderDirection.DESC, 1, 20, crit.Criter, out OutTotal);
        #endregion
        if (_ProductBuyCollection.Count < 21)
        {
            for (int i = 0; i < _ProductBuyCollectionNotgold.Count; i++)
            {
                _ProductBuyCollection.Add(_ProductBuyCollectionNotgold[i]);
                if (_ProductBuyCollection.Count > 19)
                    break;
            }
        }
        if (_ProductBuyCollection.Count > 0)
        {
            rptbuy.DataSource = _ProductBuyCollection;
            rptbuy.DataBind();
        }
    }
    protected void rptbuy_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        ProductBuy _ProductBuy = (ProductBuy)e.Item.DataItem;
        Literal ltrTitle = (Literal)e.Item.FindControl("ltrTitle");
        Literal ltrDatetime = (Literal)e.Item.FindControl("ltrDatetime");
        HtmlAnchor hrfTitle = (HtmlAnchor)e.Item.FindControl("hrfTitle");
        HtmlImage img = (HtmlImage)e.Item.FindControl("img");
        hrfTitle.HRef = "ProductBuyDetail-" + _ProductBuy.ProductId + "-" + Utilitys.StripDiacritics(Utility.Splitword(_ProductBuy.Title)) + ".aspx";
        hrfTitle.Attributes["title"] = _ProductBuy.Title;
        img.Attributes["alt"] = _ProductBuy.Title;
        ltrTitle.Text = Utilitys.ShortSummary(30, _ProductBuy.Title);
        DateTime dt = _ProductBuy.CreatedDate;
        string Day = dt.Day.ToString();
        string Month = Utilitys.converMonth(dt.Month.ToString());
        ltrDatetime.Text = Day + " " + Month;
        Criteria cri = new Criteria();
        cri.add(CompanyColumns.MemberID, _ProductBuy.MemberId, Condition.EQUAL, Condition.AND);
        CompanyCollection _CompanyCollection = CompanyService.GetCompanyListByParam(CompanyColumns.CompanyID, OrderDirection.ASC, cri.Criter);
        if (_CompanyCollection.Count > 0)
        {
            Country _Country = CountryService.GetCountry(_CompanyCollection[0].Country);
            if (_Country != null)
            {
                if (!string.IsNullOrEmpty(_Country.Img))
                {
                    img.Src = "photos/" + _Country.Img;
                }
                else
                {
                    img.Visible = false;
                }
            }
        }
    }
    #endregion
    #region Load Featured Companies
    private void LoadFeaturedCom()
    {

        int totalrecord = 0;
        #region Get Not gold member
        Criteria cri = new Criteria();
        cri.addJoin(Member._Table, ADESSA.Entities.Company._Table + "." + CompanyColumns.MemberID, Member._Table + "." + MemberColumns.MemberID, Condition.EQUAL, Condition.LEFT_JOIN);
        cri.add("[" + ADESSA.Entities.Company._Table + "].[" + CompanyColumns.Enable + "]", 1, Condition.LIKE, Condition.AND);
        cri.add(Member._Table + "." + MemberColumns.GoldMember, 0, Condition.EQUAL, Condition.AND);
        CompanyCollection _CompanyCollectionNotGold = CompanyService.GetCompanyListByParam("[" + ADESSA.Entities.Company._Table + "].[" + CompanyColumns.CreateDate + "]", OrderDirection.DESC, 1, 12, cri.Criter, out totalrecord);
        #endregion
        #region Get  gold member
        Criteria crit = new Criteria();
        crit.addJoin(Member._Table, ADESSA.Entities.Company._Table + "." + CompanyColumns.MemberID, Member._Table + "." + MemberColumns.MemberID, Condition.EQUAL, Condition.LEFT_JOIN);
        crit.add("[" + ADESSA.Entities.Company._Table + "].[" + CompanyColumns.Enable + "]", 1, Condition.LIKE, Condition.AND);
        crit.add(Member._Table + "." + MemberColumns.GoldMember, 1, Condition.EQUAL, Condition.AND);
        CompanyCollection _CompanyCollection = CompanyService.GetCompanyListByParam("[" + ADESSA.Entities.Company._Table + "].[" + CompanyColumns.CreateDate + "]", OrderDirection.DESC, 1, 12, crit.Criter, out totalrecord);
        #endregion
        if (_CompanyCollection.Count < 12)
        {
            for (int i = 0; i < _CompanyCollectionNotGold.Count; i++)
            {
                _CompanyCollection.Add(_CompanyCollectionNotGold[i]);
                if (_CompanyCollection.Count > 11)
                    break;
            }
        }
        if (_CompanyCollection.Count > 0)
        {

            dtlFeatured.DataSource = _CompanyCollection;
            dtlFeatured.DataBind();
        }
    }
    protected void dtlFeatured_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            ADESSA.Entities.Company _Company = (ADESSA.Entities.Company)e.Item.DataItem;
            HtmlAnchor ahrTitle = (HtmlAnchor)e.Item.FindControl("ahrTitle");
            HtmlImage img = (HtmlImage)e.Item.FindControl("img");
            HtmlImage imgIcon = (HtmlImage)e.Item.FindControl("imgIcon");
            Literal ltrTitle = (Literal)e.Item.FindControl("ltrTitle");
            Literal ltrStatus = (Literal)e.Item.FindControl("ltrStatus");

            ltrTitle.Text = _Company.CompanyName;
            ahrTitle.HRef = string.Format("miniweb/Default.aspx?id={0}", _Company.CompanyID);
            if (!string.IsNullOrEmpty(_Company.Logo))
                img.Src = RTISettings.NewsPictureFolder + "/" + _Company.Logo;
            #region Check Gold member
            Member _Member = MemberService.GetMember(_Company.MemberID);
            if (_Member != null)
            {
                if (_Member.GoldMember == true)
                {
                    ltrStatus.Text = "Gold Member";
                }
                else
                {
                    ltrStatus.Text = "Free Member";
                    imgIcon.Visible = false;
                }

            }
            #endregion

        }
    }
    #endregion
    #region Load Trace Show
    private void LoadTraceShow()
    {
        int total = 0;
        Criteria cri = new Criteria();
        cri.addJoin(ArticleSubCat._Table, "[" + Article._Table + "].[" + ArticleColumns.SubCatId + "]", "[" + ArticleSubCat._Table + "].[" + ArticleSubCatColumns.SubCategoryID + "]", Condition.EQUAL, Condition.LEFT_JOIN);
        cri.addJoin(ArticleCat._Table, "[" + ArticleSubCat._Table + "].[" + ArticleSubCatColumns.CategoryID + "]", "[" + ArticleCat._Table + "].[" + ArticleCatColumns.CategoryID + "]", Condition.EQUAL, Condition.LEFT_JOIN);
        cri.add(ArticleCat._Table + "." + ArticleCatColumns.Code, FetConstant.Tradeshow, Condition.EQUAL, Condition.AND);
        cri.add(Article._Table + "." + ArticleColumns.Status, 2, Condition.EQUAL, Condition.AND);
        ArticleCollection _Articlecon = ArticleService.GetArticleListByParam("[" + Article._Table + "].[" + ArticleColumns.Order + "]," + "[" + Article._Table + "].[" + ArticleColumns.CreatedDate + "]", OrderDirection.DESC, 1, 2, cri.Criter, out total);
        if (_Articlecon.Count > 0)
        {
            rptTraceShow.DataSource = _Articlecon;
            rptTraceShow.DataBind();

        }

    }
    protected void rptTraceShow_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Article _Article = (Article)e.Item.DataItem;
            HtmlAnchor ahrTitle = (HtmlAnchor)e.Item.FindControl("ahrTitle");
            Literal ltrTitle = (Literal)e.Item.FindControl("ltrTitle");
            Literal ltrDate = (Literal)e.Item.FindControl("ltrDate");
            Literal ltrSum = (Literal)e.Item.FindControl("ltrSum");

            ltrTitle.Text = _Article.Title;
            ltrSum.Text = _Article.Summary;
            ltrDate.Text = Utility.GetFormattedDate(_Article.CreatedDate);



        }
    }
    #endregion
    #region Load Feature country
    private void LoadFeatureCountry()
    {
        int total = 0;
        Criteria cri = new Criteria();
        cri.addJoin(ArticleSubCat._Table, "[" + Article._Table + "].[" + ArticleColumns.SubCatId + "]", "[" + ArticleSubCat._Table + "].[" + ArticleSubCatColumns.SubCategoryID + "]", Condition.EQUAL, Condition.LEFT_JOIN);
        cri.addJoin(ArticleCat._Table, "[" + ArticleSubCat._Table + "].[" + ArticleSubCatColumns.CategoryID + "]", "[" + ArticleCat._Table + "].[" + ArticleCatColumns.CategoryID + "]", Condition.EQUAL, Condition.LEFT_JOIN);
        cri.add(ArticleCat._Table + "." + ArticleCatColumns.Code, FetConstant.Featurecountry, Condition.EQUAL, Condition.AND);
        cri.add(Article._Table + "." + ArticleColumns.Status, 2, Condition.EQUAL, Condition.AND);
        ArticleCollection _Articlecon = ArticleService.GetArticleListByParam("[" + Article._Table + "].[" + ArticleColumns.Order + "]," + "[" + Article._Table + "].[" + ArticleColumns.CreatedDate + "]", OrderDirection.DESC, 1, 4, cri.Criter, out total);
        if (_Articlecon.Count > 0)
        {
            CountArticle = _Articlecon.Count;
            Article _Article = _Articlecon[0];
            ltrTitleFeatureCountry.Text = _Article.Title;
            if (!string.IsNullOrEmpty(_Article.Image))
                imgFeatureCountry.Src = "photos/" + _Article.Image;
            _Articlecon.RemoveAt(0);
            rptFeatureCountry.DataSource = _Articlecon;
            rptFeatureCountry.DataBind();

        }

    }
    protected void rptFeatureCountry_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Article _Article = (Article)e.Item.DataItem;
            HtmlAnchor ahrTitle = (HtmlAnchor)e.Item.FindControl("ahrTitle");
            Literal ltrTitle = (Literal)e.Item.FindControl("ltrTitle");
            HtmlControl divline_trade_show = (HtmlControl)e.Item.FindControl("divline_trade_show");
            ltrTitle.Text = _Article.Title;
            ahrTitle.HRef = "Detail-" + _Article.ArticleId.ToString() + "-" + Utilitys.StripDiacritics(Utility.Splitword(_Article.Title)) + ".aspx";
            int STT = NoCountStart + e.Item.ItemIndex;
            if (STT == CountArticle - 2)
            {
                divline_trade_show.Visible = false;
            }


        }
    }
    #endregion
}
